//
//  LJYReadTableViewCell.m
//  WWLNetease
//
//  Created by 李锦耀 on 15/12/25.
//  Copyright © 2015年 Echo.Jobs. All rights reserved.
//

#import "LJYReadTableViewCell.h"

@interface LJYReadTableViewCell ()

@property(nonatomic, strong)UIImageView *titleImage;
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *dateLabel;

@end

@implementation LJYReadTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self creatAction];
    }
    return self;
}

-(void)creatAction
{
    _titleImage = [[UIImageView alloc] init];
    _titleImage.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:_titleImage];
    [_titleImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(self.contentView).offset(15);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(70);
        
    }];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.numberOfLines = 0;
    _titleLabel.font = [UIFont boldSystemFontOfSize:15];
    _titleLabel.textColor = [UIColor colorWithRed:0.82 green:0.81 blue:0.76 alpha:1];
    _titleLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.titleImage);
        make.left.equalTo(self.titleImage.mas_right).offset(10);
        make.right.equalTo(self.contentView).offset(-20);
        make.height.mas_equalTo(40);
        
    }];
    
    _dateLabel = [[UILabel alloc] init];
    _dateLabel.font = [UIFont systemFontOfSize:15];
    _dateLabel.textAlignment = NSTextAlignmentRight;
    _dateLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_dateLabel];
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.titleImage.mas_right).offset(10);
        make.bottom.equalTo(self.contentView).offset(-15);
        make.right.equalTo(self.contentView).offset(-10);
        make.height.mas_equalTo(20);
        
    }];
    
}

-(void)setRead:(LJYReadModel *)read
{
    [self.titleImage sd_setImageWithURL:[NSURL URLWithString:read.imgsrc] placeholderImage:[UIImage imageNamed:@"u=1625671141,2113623839&fm=21&gp=0.jpg"]];
    self.titleLabel.text = read.title;
    self.dateLabel.text = read.ptime;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
